package com.jhgk.jhcee.system.controller;

import com.jhgk.jhcee.common.resultful.BasisResultful;
import com.jhgk.jhcee.system.domain.model.SysPermissionInfoModel;
import com.jhgk.jhcee.system.service.SysPermissionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description:
 * @Author: lemon_xzp
 * @Date: 2021/9/22 16:42
 */
@RestController
@RequestMapping("/permission")
@Api(value = "权限信息", tags = {"权限信息"})
public class SysPermissionInfoController {

    @Resource(name = "SysPermissionInfoServiceImpl")
    SysPermissionInfoService sysPermissionService;

    @GetMapping("/getPermissionList")
    @ApiOperation("获取用户权限列表")
    public BasisResultful<Object> getPermissionList() {
        return sysPermissionService.getPermissionList();
    }

    @PostMapping("/getPermissionAllList")
    @ApiOperation("获取所有权限记录信息")
    public BasisResultful<Object> getPermissionAllList(@RequestBody SysPermissionInfoModel sysPermissionInfoModel) {
        return sysPermissionService.getPermissionAllList(sysPermissionInfoModel);
    }

    @PostMapping("/addPermission")
    @ApiOperation("新增权限记录信息")
    public BasisResultful<Object> addPermission(@RequestBody SysPermissionInfoModel sysPermissionInfoModel) {
        return sysPermissionService.addPermission(sysPermissionInfoModel);
    }

    @PutMapping("/updatePermission")
    @ApiOperation("修改权限记录信息")
    public BasisResultful<Object> updatePermission(@RequestBody SysPermissionInfoModel sysPermissionInfoModel) {
        return sysPermissionService.updatePermission(sysPermissionInfoModel);
    }

    @DeleteMapping("/deletePermission")
    @ApiOperation("删除权限记录")
    public BasisResultful<Object> deletePermission(@RequestBody SysPermissionInfoModel sysPermissionInfoModel) {
        return sysPermissionService.deletePermission(sysPermissionInfoModel);
    }

    @PostMapping("/setPermissionStatus")
    @ApiOperation("更改权限记录状态")
    public BasisResultful<Object> setPermissionStatus(@RequestBody SysPermissionInfoModel model) {
        return sysPermissionService.setPermissionStatus(model.getPermissionId(), model.getStatus());
    }
}
